home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / what's new / development kits / mac os / nsl 1.1 sdk / headers / nsl.h next >
Encoding:
C/C++ Source or Header  |  1999-10-12  |  32.8 KB  |  834 lines

  1. /*
  2.      File:        NSL.h
  3.  
  4.      Contains:    Interface to API for using the NSL Manager
  5.  
  6.      Version:    Mac OS 8.5
  7.  
  8.      DRI:        Kevin Arnold
  9.  
  10.      Copyright:    © 1985-1999 by Apple Computer, Inc., all rights reserved
  11.  
  12.      Warning:    *** APPLE INTERNAL USE ONLY ***
  13.                  This file may contain unreleased API's
  14.  
  15.      BuildInfo:    Built by:            Steven Simon
  16.                  On:                    8/23/99 9:44 AM
  17.                  With Interfacer:    3.0d13   (MPW PowerPC)
  18.                  From:                NSL.i
  19.                      Revision:        26
  20.                      Dated:            08/23/99
  21.                      Last change by:    sns
  22.                      Last comment:    update comments
  23.  
  24.      Bugs:        Report bugs to Radar component "System Interfaces", "Latest"
  25.                  List the version information (from above) in the Problem Description.
  26.  
  27. */
  28. #ifndef __NSL__
  29. #define __NSL__
  30.  
  31. #ifndef __CODEFRAGMENTS__
  32. #include <CodeFragments.h>
  33. #endif
  34.  
  35. #ifndef __EVENTS__
  36. #include <Events.h>
  37. #endif
  38.  
  39. #ifndef __THREADS__
  40. #include <Threads.h>
  41. #endif
  42.  
  43.  
  44.  
  45. #if PRAGMA_ONCE
  46. #pragma once
  47. #endif
  48.  
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52.  
  53. #if PRAGMA_IMPORT
  54. #pragma import on
  55. #endif
  56.  
  57. #if PRAGMA_STRUCT_ALIGN
  58.     #pragma options align=mac68k
  59. #elif PRAGMA_STRUCT_PACKPUSH
  60.     #pragma pack(push, 2)
  61. #elif PRAGMA_STRUCT_PACK
  62.     #pragma pack(2)
  63. #endif
  64.  
  65. #pragma export on
  66.  
  67. enum {
  68.     kNSLMinSystemVersion        = 0x0900,                        /* equivalent to 9.0*/
  69.     kNSLMinOTVersion            = 0x0130                        /* equivalent to 1.3*/
  70. };
  71.  
  72. enum {
  73.     kNSLDefaultListSize            = 256                            /* default list size for service and protocol lists*/
  74. };
  75.  
  76. enum {
  77.     kNSLURLDelimiter            = ','                            /* delimits URL's within memory buffers*/
  78. };
  79.  
  80.  
  81. #define    kNSLErrorNoErr                {noErr, kNSLNoContext}        /* an initializer for the NSLError struct */
  82.  
  83. enum {
  84.     kNSLNoContext                = 0                                /* the default context for NSLError structs*/
  85. };
  86.  
  87.  
  88. struct NSLError {
  89.     OSStatus                         theErr;
  90.     UInt32                             theContext;
  91. };
  92. typedef struct NSLError                    NSLError;
  93. typedef NSLError *                        NSLErrorPtr;
  94. enum {
  95.                                                                 /* Constants to use with NSLPrepareRequest*/
  96.                                                                 /* kNSLDuplicateSearchInProgress is not strictly an error.  The client is free to ignore*/
  97.                                                                 /* this result, and nothing bad will happen if it does.  It is*/
  98.                                                                 /* informational only.*/
  99.     kNSLDuplicateSearchInProgress = 100,
  100.     kNSLUserCanceled            = userCanceledErr,                /* User hit cancel from the NSLStandardGetURL dialog */
  101.                                                                 /* Invalid enumeratorRef    */
  102.     kNSLInvalidEnumeratorRef    = 0                                /* this is not an error; it is the equiv to a NULL ptr*/
  103. };
  104.  
  105.  
  106. typedef UInt16 NSLSearchState;
  107. enum {
  108.                                                                 /* State codes for notifiers.*/
  109.     kNSLSearchStateBufferFull    = 1,
  110.     kNSLSearchStateOnGoing        = 2,
  111.     kNSLSearchStateComplete        = 3,
  112.     kNSLSearchStateStalled        = 4,
  113.     kNSLWaitingForContinue        = 5
  114. };
  115.  
  116.  
  117. typedef UInt32 NSLEventCode;
  118. enum {
  119.                                                                 /* Event codes*/
  120.     kNSLServicesLookupDataEvent    = 6,
  121.     kNSLNeighborhoodLookupDataEvent = 7,
  122.     kNSLNewDataEvent            = 8,
  123.     kNSLContinueLookupEvent        = 9
  124. };
  125.  
  126. enum {
  127.                                                                 /* Error codes*/
  128.     kNSLNavigationAPIErrorBase    = -4200,                        /* UNABLE TO INITIALIZE THE MANAGER!!!!!*/
  129.                                                                 /* DO NOT CONTINUE!!!!*/
  130.     kNSLInitializationFailed    = kNSLNavigationAPIErrorBase,    /* General NSL error codes.*/
  131.     kNSLNotInitialized            = -4199,
  132.     kNSLInsufficientSysVer        = -4198,
  133.     kNSLInsufficientOTVer        = -4197,
  134.     kNSLNoElementsInList        = -4196,
  135.     kNSLBadReferenceErr            = -4195,
  136.     kNSLBadServiceTypeErr        = -4194,
  137.     kNSLBadDataTypeErr            = -4193,
  138.     kNSLBadNetConnection        = -4192,
  139.     kNSLNoSupportForService        = -4191,
  140.     kNSLInvalidPluginSpec        = -4190,
  141.     kNSLRequestBufferAlreadyInList = -4189,
  142.     kNSLNoContextAvailable        = -4188,                        /* (ContinueLookup function ptr invalid)*/
  143.     kNSLBufferTooSmallForData    = -4187,                        /* (Client buffer too small for data from plugin)*/
  144.     kNSLCannotContinueLookup    = -4186,                        /* (Can't continue lookup; error or bad state)*/
  145.     kNSLBadClientInfoPtr        = -4185,                        /* (nil ClientAsyncInfoPtr; no reference available)*/
  146.     kNSLNullListPtr                = -4184,                        /* (client is trying to add items to a nil list)*/
  147.     kNSLBadProtocolTypeErr        = -4183,                        /* (client is trying to add a null protocol type)*/
  148.     kNSLPluginLoadFailed        = -4182,                        /* (manager unable to load one of the plugins)*/
  149.     kNSLNoPluginsFound            = -4181,                        /* (manager didn't find any valid plugins to load)*/
  150.     kNSLSearchAlreadyInProgress    = -4180,                        /* (you can only have one ongoing search per clientRef)*/
  151.     kNSLNoPluginsForSearch        = -4179,                        /* (no plugins will respond to search request; bad protocol(s)?)*/
  152.     kNSLNullNeighborhoodPtr        = -4178,                        /* (client passed a null neighborhood ptr)*/
  153.     kNSLSomePluginsFailedToLoad    = -4177,                        /* (one or more plugins failed to load, but at*/
  154.                                                                 /* least one did load; this error isn't fatal)*/
  155.     kNSLErrNullPtrError            = -4176,
  156.     kNSLNotImplementedYet        = -4175,
  157.     kNSLUILibraryNotAvailable    = -4174,                        /* The NSL UI Library needs to be in the Extensions Folder*/
  158.     kNSLNoCarbonLib                = -4173,
  159.     kNSLBadURLSyntax            = -4172,                        /* URL contains illegal characters*/
  160.     kNSLSchedulerError            = -4171,                        /* A custom thread routine encountered an error*/
  161.     kNSL68kContextNotSupported    = -4170,                        /* no 68k allowed*/
  162.     kNSLLastAndMeaningLessItemInNSLEnum = -4169
  163. };
  164.  
  165.  
  166. typedef UInt32                             NSLClientRef;
  167. typedef UInt32                             NSLRequestRef;
  168. typedef UInt32                             NSLOneBasedIndex;
  169. typedef char *                            NSLPath;
  170. typedef char *                            NSLServiceType;
  171. typedef Handle                             NSLServicesList;
  172. typedef unsigned char *                    NSLNeighborhood;
  173. /*
  174.    cstring which is a comma delimited list of protocols which can be used to
  175.    create a NSLProtocolList internally
  176. */
  177.  
  178. typedef UInt32 NSLDialogOptionFlags;
  179. enum {
  180.     kNSLDefaultNSLDlogOptions    = 0x00000000,                    /* use defaults for all the options */
  181.     kNSLNoURLTEField            = 0x00000001                    /* don't show url text field for manual entry */
  182. };
  183.  
  184.  
  185.  
  186. struct NSLDialogOptions {
  187.     UInt16                             version;
  188.     NSLDialogOptionFlags             dialogOptionFlags;            /* option flags for affecting the dialog's behavior */
  189.     Str255                             windowTitle;
  190.     Str255                             actionButtonLabel;            /* label of the default button (or null string for default) */
  191.     Str255                             cancelButtonLabel;            /* label of the cancel button (or null string for default) */
  192.     Str255                             message;                    /* custom message prompt (or null string for default) */
  193. };
  194. typedef struct NSLDialogOptions            NSLDialogOptions;
  195.  
  196. /* the async information block for client<->manager interaction*/
  197.  
  198. struct NSLClientAsyncInfo {
  199.     void *                            clientContextPtr;            /* set by the client for its own use*/
  200.     void *                            mgrContextPtr;                /* set by NSL mgr; ptr to request object ptr*/
  201.     char *                            resultBuffer;
  202.     long                             bufferLen;
  203.     long                             maxBufferSize;
  204.     UInt32                             startTime;                    /* when the search starts, to use with maxSearchTime to determine time-out condition*/
  205.     UInt32                             intStartTime;                /* used with alertInterval*/
  206.     UInt32                             maxSearchTime;                /* total time for search, in ticks (0 == no time limit)*/
  207.     UInt32                             alertInterval;                /* call client's notifier or return, every this many ticks ( 0 == don't use this param)*/
  208.     UInt32                             totalItems;                    /* total number of tuples currently in buffer*/
  209.     UInt32                             alertThreshold;                /* call client's notifier or return, every this many items found ( 0 == don't use this param)*/
  210.     NSLSearchState                     searchState;
  211.     NSLError                         searchResult;
  212.     NSLEventCode                     searchDataType;                /* this is a data type code which allows the client's asyncNotifier to properly*/
  213.                                                                 /* handle the data in resultBuffer.*/
  214. };
  215. typedef struct NSLClientAsyncInfo        NSLClientAsyncInfo;
  216. typedef NSLClientAsyncInfo *            NSLClientAsyncInfoPtr;
  217.  
  218. /* the async information block plugin<->manager interaction*/
  219.  
  220. struct NSLPluginAsyncInfo {
  221.     void *                            mgrContextPtr;                /* set by NSL mgr; ptr to request object ptr*/
  222.     void *                            pluginContextPtr;            /* set/used by individual plugins*/
  223.     void *                            pluginPtr;                    /* ptr to the plugin object waiting for continue lookup call*/
  224.     char *                            resultBuffer;                /* set by plugin to point at data*/
  225.     long                             bufferLen;
  226.     long                             maxBufferSize;
  227.     UInt32                             maxSearchTime;                /* total time for search, in ticks (0 == no time limit)*/
  228.     UInt32                             reserved1;
  229.     UInt32                             reserved2;
  230.     UInt32                             reserved3;
  231.     NSLClientRef                     clientRef;
  232.     NSLRequestRef                     requestRef;
  233.     NSLSearchState                     searchState;
  234.     OSStatus                         searchResult;
  235. };
  236. typedef struct NSLPluginAsyncInfo        NSLPluginAsyncInfo;
  237. typedef NSLPluginAsyncInfo *            NSLPluginAsyncInfoPtr;
  238.  
  239. /* the mgr asynchronous notifier routine.*/
  240. typedef CALLBACK_API( void , NSLMgrNotifyProcPtr )(NSLPluginAsyncInfo *thePluginAsyncInfo);
  241.  
  242. /* the client asynchronous notifier routine.*/
  243. typedef CALLBACK_API( void , NSLClientNotifyProcPtr )(NSLClientAsyncInfo *theClientAsyncInfo);
  244. typedef STACK_UPP_TYPE(NSLMgrNotifyProcPtr)                     NSLMgrNotifyUPP;
  245. typedef STACK_UPP_TYPE(NSLClientNotifyProcPtr)                     NSLClientNotifyUPP;
  246. #if OPAQUE_UPP_TYPES
  247.     EXTERN_API(NSLMgrNotifyUPP)
  248.     NewNSLMgrNotifyUPP               (NSLMgrNotifyProcPtr        userRoutine);
  249.  
  250.     EXTERN_API(NSLClientNotifyUPP)
  251.     NewNSLClientNotifyUPP           (NSLClientNotifyProcPtr    userRoutine);
  252.  
  253.     EXTERN_API(void)
  254.     DisposeNSLMgrNotifyUPP           (NSLMgrNotifyUPP            userUPP);
  255.  
  256.     EXTERN_API(void)
  257.     DisposeNSLClientNotifyUPP       (NSLClientNotifyUPP        userUPP);
  258.  
  259.     EXTERN_API(void)
  260.     InvokeNSLMgrNotifyUPP           (NSLPluginAsyncInfo *    thePluginAsyncInfo,
  261.                                     NSLMgrNotifyUPP            userUPP);
  262.  
  263.     EXTERN_API(void)
  264.     InvokeNSLClientNotifyUPP       (NSLClientAsyncInfo *    theClientAsyncInfo,
  265.                                     NSLClientNotifyUPP        userUPP);
  266.  
  267. #else
  268.     enum { uppNSLMgrNotifyProcInfo = 0x000000C0 };                     /* pascal no_return_value Func(4_bytes) */
  269.     enum { uppNSLClientNotifyProcInfo = 0x000000C0 };                 /* pascal no_return_value Func(4_bytes) */
  270.     #define NewNSLMgrNotifyUPP(userRoutine)                         (NSLMgrNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLMgrNotifyProcInfo, GetCurrentArchitecture())
  271.     #define NewNSLClientNotifyUPP(userRoutine)                         (NSLClientNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLClientNotifyProcInfo, GetCurrentArchitecture())
  272.     #define DisposeNSLMgrNotifyUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  273.     #define DisposeNSLClientNotifyUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  274.     #define InvokeNSLMgrNotifyUPP(thePluginAsyncInfo, userUPP)         CALL_ONE_PARAMETER_UPP((userUPP), uppNSLMgrNotifyProcInfo, (thePluginAsyncInfo))
  275.     #define InvokeNSLClientNotifyUPP(theClientAsyncInfo, userUPP)     CALL_ONE_PARAMETER_UPP((userUPP), uppNSLClientNotifyProcInfo, (theClientAsyncInfo))
  276. #endif
  277. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  278. #define NewNSLMgrNotifyProc(userRoutine)                         NewNSLMgrNotifyUPP(userRoutine)
  279. #define NewNSLClientNotifyProc(userRoutine)                     NewNSLClientNotifyUPP(userRoutine)
  280. #define CallNSLMgrNotifyProc(userRoutine, thePluginAsyncInfo)    InvokeNSLMgrNotifyUPP(thePluginAsyncInfo, userRoutine)
  281. #define CallNSLClientNotifyProc(userRoutine, theClientAsyncInfo) InvokeNSLClientNotifyUPP(theClientAsyncInfo, userRoutine)
  282.  
  283. /*
  284.    this struct is a format for dealing with our internal data representation.  Typed data will be contiguous chunk of
  285.    memory, with the first 4 bytes being a data "descriptor".
  286. */
  287.  
  288. struct NSLTypedData {
  289.     unsigned long                     dataType;
  290.     unsigned long                     lengthOfData;
  291. //    void*                            theData;
  292.  
  293. };
  294. typedef struct NSLTypedData                NSLTypedData;
  295. typedef NSLTypedData *                    NSLTypedDataPtr;
  296.  
  297. #define kNSLDataType                'NSL_'
  298. /*
  299.    This is just a header at the beginning of a handle that stores our list of service types.
  300.    Each service type is a pascal string, so each service type starts after the end of the
  301.    previous one.
  302. */
  303.  
  304. struct NSLServicesListHeader {
  305.     unsigned long                     numServices;
  306.     unsigned long                     logicalLen;                    /* length of all usable data in handle*/
  307. //    Ptr                                firstService;
  308.  
  309. };
  310. typedef struct NSLServicesListHeader    NSLServicesListHeader;
  311. typedef NSLServicesListHeader *            NSLServicesListHeaderPtr;
  312.  
  313. /* some defs for common protocols*/
  314.  
  315. #define    kSLPProtocolType            "SLP"
  316. #define    kDNSProtocolType            "DNS"
  317. #define    kLDAPProtocolType            "LDAP"
  318. #define kNBPProtocolType            "NBP"
  319.  
  320. /*
  321.    general information from a plug-in.  Includes supported protocols, data types and services,
  322.    as well as an info/comment string describing the function of the plug-in in human-readable
  323.    form.  The offsets point to the beginning of each list of data returned, and the protocol
  324.    data offset is the startOfData member of the struct
  325. */
  326.  
  327. struct NSLPluginData {
  328.     long                             reserved1;
  329.     long                             reserved2;
  330.     long                             reserved3;
  331.     Boolean                         supportsRegistration;
  332.     Boolean                         isPurgeable;
  333.     UInt16                             totalLen;                    /* length of everything, including header*/
  334.     UInt16                             dataTypeOffset;
  335.     UInt16                             serviceListOffset;
  336.     UInt16                             protocolListOffset;
  337.     UInt16                             commentStringOffset;
  338. //    char*                            startOfData;
  339.                                                                 /* protocol data is first on the list*/
  340. };
  341. typedef struct NSLPluginData            NSLPluginData;
  342. typedef NSLPluginData *                    NSLPluginDataPtr;
  343.  
  344. /*
  345.   -----------------------------------------------------------------------------
  346.       Finding out if the library is present and getting its version
  347.   -----------------------------------------------------------------------------
  348. */
  349.  
  350. EXTERN_API( UInt32 )
  351. NSLLibraryVersion                (void);
  352.  
  353.  
  354.  
  355.     #ifdef __cplusplus
  356.         inline pascal Boolean NSLLibraryPresent() { return NSLLibraryVersion != (void*)kUnresolvedCFragSymbolAddress; }
  357.     #else
  358.         #define NSLLibraryPresent()        ((NSLLibraryVersion != (void*)kUnresolvedCFragSymbolAddress))
  359.     #endif
  360.     
  361. typedef CALLBACK_API( Boolean , NSLURLFilterProcPtr )(char *url, Str255 displayString)/*  optional filter function */;
  362. /* you can provide for calls to NSLStandardGetURL*/
  363. typedef CALLBACK_API( void , NSLEventProcPtr )(EventRecord *newEvent, void *userContext)/*  optional callback routine for getting Events while the dialog is up */;
  364. typedef STACK_UPP_TYPE(NSLURLFilterProcPtr)                     NSLURLFilterUPP;
  365. typedef STACK_UPP_TYPE(NSLEventProcPtr)                         NSLEventUPP;
  366. #if OPAQUE_UPP_TYPES
  367.     EXTERN_API(NSLURLFilterUPP)
  368.     NewNSLURLFilterUPP               (NSLURLFilterProcPtr        userRoutine);
  369.  
  370.     EXTERN_API(NSLEventUPP)
  371.     NewNSLEventUPP                   (NSLEventProcPtr            userRoutine);
  372.  
  373.     EXTERN_API(void)
  374.     DisposeNSLURLFilterUPP           (NSLURLFilterUPP            userUPP);
  375.  
  376.     EXTERN_API(void)
  377.     DisposeNSLEventUPP               (NSLEventUPP                userUPP);
  378.  
  379.     EXTERN_API(Boolean)
  380.     InvokeNSLURLFilterUPP           (char *                    url,
  381.                                     Str255                    displayString,
  382.                                     NSLURLFilterUPP            userUPP);
  383.  
  384.     EXTERN_API(void)
  385.     InvokeNSLEventUPP               (EventRecord *            newEvent,
  386.                                     void *                    userContext,
  387.                                     NSLEventUPP                userUPP);
  388.  
  389. #else
  390.     enum { uppNSLURLFilterProcInfo = 0x000003D0 };                     /* pascal 1_byte Func(4_bytes, 4_bytes) */
  391.     enum { uppNSLEventProcInfo = 0x000003C0 };                         /* pascal no_return_value Func(4_bytes, 4_bytes) */
  392.     #define NewNSLURLFilterUPP(userRoutine)                         (NSLURLFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLURLFilterProcInfo, GetCurrentArchitecture())
  393.     #define NewNSLEventUPP(userRoutine)                             (NSLEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLEventProcInfo, GetCurrentArchitecture())
  394.     #define DisposeNSLURLFilterUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  395.     #define DisposeNSLEventUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  396.     #define InvokeNSLURLFilterUPP(url, displayString, userUPP)         CALL_TWO_PARAMETER_UPP((userUPP), uppNSLURLFilterProcInfo, (url), (displayString))
  397.     #define InvokeNSLEventUPP(newEvent, userContext, userUPP)         CALL_TWO_PARAMETER_UPP((userUPP), uppNSLEventProcInfo, (newEvent), (userContext))
  398. #endif
  399. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  400. #define NewNSLURLFilterProc(userRoutine)                         NewNSLURLFilterUPP(userRoutine)
  401. #define NewNSLEventProc(userRoutine)                             NewNSLEventUPP(userRoutine)
  402. #define CallNSLURLFilterProc(userRoutine, url, displayString)    InvokeNSLURLFilterUPP(url, displayString, userRoutine)
  403. #define CallNSLEventProc(userRoutine, newEvent, userContext)    InvokeNSLEventUPP(newEvent, userContext, userRoutine)
  404.  
  405. /*
  406.   -----------------------------------------------------------------------------
  407.       High level API calls: the following two calls are ALL an application needs
  408.        to register/deregister its service.
  409.     If you use these, you don't need to make any of the other calls to NSLAPI 
  410.       (including NSLOpenNavigationAPI) 
  411.   -----------------------------------------------------------------------------
  412. */
  413.  
  414. /* <--- error code from registration */
  415. /* ---> urlToRegister is a null terminated url that has only legal characters defined for URLs.  Use HexEncodeText to encode*/
  416. /*            portions of the url that have illegal characters */
  417. /* ---> neighborhoodToRegisterIn is an optional parameter for explicitly defining a neighborhood to register in.
  418.             If parameter is NULL, then the plugins will determine where to register the service */
  419. EXTERN_API( NSLError )
  420. NSLStandardRegisterURL            (NSLPath                 urlToRegister,
  421.                                  NSLNeighborhood         neighborhoodToRegisterIn) /* can be NULL */;
  422.  
  423. /* <--- error code from registration */
  424. /* ---> urlToRegister is a null terminated url that has only legal characters defined for URLs.  Use HexEncodeText to encode*/
  425. /*            portions of the url that have illegal characters */
  426. /* ---> neighborhoodToDeregisterIn is an optional parameter for explicitly defining a neighborhood to register in.
  427.             If parameter is NULL, then the plugins will determine where to register the service */
  428. EXTERN_API( NSLError )
  429. NSLStandardDeregisterURL        (NSLPath                 urlToDeregister,
  430.                                  NSLNeighborhood         neighborhoodToDeregisterIn) /* can be NULL */;
  431.  
  432. /* <--- function returns OSStatus of the operation.  noErr will be returned if valid, kNSLUserCanceled will be returned if the user cancels */
  433. /* ---> dialogOptions */
  434. /* ---> eventProc */
  435. /* ---> eventProcContextPtr */
  436. /* ---> filterProc */
  437. /* ---> serviceTypeList */
  438. /* <--- userSelectedURL */
  439. /* NSLDialogOptions* dialogOptions */
  440. /*
  441.    dialogOptions is a user defined structure defining the look, feel and operation of NSLStandardGetURL dialog
  442.    default behavior can be achieved by passing in a pointer to a structure that has been filled out by a previous
  443.    call to NSLGetDefaultDialogOptions or by passing in NULL.
  444. */
  445. /* NSLEventUPP eventProc */
  446. /*
  447.    the eventProc is a callback NSLURLFilterUPP that will
  448.    get called with Events that the dialog doesn't handle.  If you pass in nil,
  449.    you won't get update events while the NSLStandardGetURL dialog is open.
  450. */
  451. /* void* eventProcContextPtr */
  452. /* you can provide a pointer to some contextual data that you want to have sent to your eventProc filter*/
  453. /* NSLURLFilterProcPtr filterProc */
  454. /*
  455.    the filter param is a callback NSLURLFilterUPP that
  456.    will get called (if not nil) for each url that is going to be displayed in
  457.    the dialog's result list.  A result of false will not include the url for the
  458.    user to select from.  You also have the option of handling the way the url looks
  459.    in the dialog listing by copying the preferred name into the displayString
  460.    parameter.  (If left alone, NSLStandardGetURL dialog will strip the service type
  461.    portion off the url).
  462. */
  463. /* char* serviceTypeList */
  464. /*
  465.    the serviceTypeList parameter is a null terminated string that will 
  466.    directly affect the contents of the services popup in the dialog.
  467.    The structure of this string is a set of tuples as follows:
  468.    Name of ServiceType as to be represented in the popup followed by
  469.    a comma delimted list of service descriptors (ie http,https) that will
  470.    used in the search of that type.  Each comma delimited tuple is delimited
  471.    by semi-colons.
  472. */
  473. /*
  474.    For example:
  475.    If you want to search for services of type http (web), https (secure web),
  476.    and ftp, you could pass in the string "Web Servers,http,https;FTP Servers,ftp".
  477.    This would result in a popup list with two items ("Web Servers" and "FTP Servers")
  478.    and searches performed on them will provide results of type http and https for the
  479.    first, and ftp for the second.
  480. */
  481.  
  482. /*
  483.    Results list Icons:
  484.    NSLStandardGetURL provides icons in its listings for the following types:
  485.    "http", "https", "ftp", "afp", "lpr", "LaserWriter", "AFPServer"
  486.    any other types will get a generic icon.  However, you can provide icons
  487.    if you wish by including an '#ics8' resource id at the end of your comma
  488.    delimited list.  The dialog will then use that icon if found in its results
  489.    list.  This icon will be used for all types in a tuple.
  490.    For example:
  491.    The param "Web Servers,http,https;Telnet Servers,telnet;NFS Servers,nfs,129"
  492.    would result in lists of http and https services to be shown with their default
  493.    icons, telnet servers would be shown with the default misc. icon and nfs
  494.    servers would be shown with your icon at resource id 129.
  495. */
  496.  
  497. /* char** url */
  498. /*
  499.    pass in the address of a char* and it will point to the resulting url.  If the user
  500.    cancels (the function returns false), the pointer will be set to nil.  If the function
  501.    returns true (user selected a url), then you must call NSLFreeURL on the pointer when
  502.    you are done with it.
  503. */
  504. /*
  505.    Call this to have the user select a url based service from a dialog.
  506.    Function takes on input an optional filter proc, a serviceTypeList, and an address to a Ptr.
  507.    Function sets the value of the Ptr to a newly created c-style null terminated string
  508.    containing the user's choice of URL.
  509. */
  510.  
  511. EXTERN_API( OSStatus )
  512. NSLStandardGetURL                (NSLDialogOptions *        dialogOptions, /* can be NULL */
  513.                                  NSLEventUPP             eventProc, /* can be NULL */
  514.                                  void *                    eventProcContextPtr, /* can be NULL */
  515.                                  NSLURLFilterUPP         filterProc, /* can be NULL */
  516.                                  char *                    serviceTypeList,
  517.                                  char **                userSelectedURL);
  518.  
  519. /*-----------------------------------------------------------------------------*/
  520.  
  521. EXTERN_API( OSStatus )
  522. NSLHexEncodeText                (const char *            rawText,
  523.                                  UInt16                 rawTextLen,
  524.                                  char *                    newTextBuffer,
  525.                                  UInt16 *                newTextBufferLen,
  526.                                  Boolean *                textChanged);
  527.  
  528. EXTERN_API( OSStatus )
  529. NSLHexDecodeText                (const char *            encodedText,
  530.                                  UInt16                 encodedTextLen,
  531.                                  char *                    decodedTextBuffer,
  532.                                  UInt16 *                decodedTextBufferLen,
  533.                                  Boolean *                textChanged);
  534.  
  535. EXTERN_API( OSStatus )
  536. NSLGetDefaultDialogOptions        (NSLDialogOptions *        dialogOptions);
  537.  
  538. /* <--- function returns null (useful for setting variable at same time as freeing it */
  539. /* ---> url is memory created by a call to NSLStandardGetURL */
  540. EXTERN_API( char *)
  541. NSLFreeURL                        (char *                    url);
  542.  
  543. /*
  544.   -----------------------------------------------------------------------------
  545.       Basic API Utility calls: sufficient to create, and parse data structures
  546.   -----------------------------------------------------------------------------
  547. */
  548.  
  549. EXTERN_API( NSLServicesList )
  550. NSLMakeNewServicesList            (const char *            initialServiceList);
  551.  
  552. EXTERN_API( NSLError )
  553. NSLAddServiceToServicesList        (NSLServicesList         serviceList,
  554.                                  NSLServiceType         serviceType);
  555.  
  556. EXTERN_API( void )
  557. NSLDisposeServicesList            (NSLServicesList         theList);
  558.  
  559. /*
  560.     The name reflects the name of the Neighborhood, i.e. "apple.com." or "AppleTalk Zone One".
  561.     The protocolList is a comma delimited list of protocols that the Neighborhood might exist in.
  562.     If the user passes in NULL, then all protocols will be queried.  The result must be disposed
  563.     of by the user by calling NSLFreeNeighborhood.
  564. */
  565. EXTERN_API( NSLNeighborhood )
  566. NSLMakeNewNeighborhood            (const char *            name,
  567.                                  const char *            protocolList) /* can be NULL */;
  568.  
  569. /* creates an exact copy of an existing neighborhood */
  570. EXTERN_API( NSLNeighborhood )
  571. NSLCopyNeighborhood                (NSLNeighborhood         neighborhood);
  572.  
  573. EXTERN_API( NSLNeighborhood )
  574. NSLFreeNeighborhood                (NSLNeighborhood         neighborhood);
  575.  
  576. EXTERN_API( void )
  577. NSLGetNameFromNeighborhood        (NSLNeighborhood         neighborhood,
  578.                                  char **                name,
  579.                                  long *                    length);
  580.  
  581. /*
  582.    create a block of formatted data, pointed to by newDataPtr.  This will be used
  583.    in calls (typically request-related calls) for plug-ins that handle the NSL data type.
  584. */
  585. EXTERN_API( OSStatus )
  586. NSLMakeServicesRequestPB        (NSLServicesList         serviceList,
  587.                                  NSLTypedDataPtr *        newDataPtr);
  588.  
  589. /* releases any storage created with MakeXXXPB calls, associated with TypedData.*/
  590. EXTERN_API( NSLTypedDataPtr )
  591. NSLFreeTypedDataPtr                (NSLTypedDataPtr         nslTypeData);
  592.  
  593. /*
  594.    utility function that returns whether a url was found, a pointer to the beginning
  595.    of the url, and the length of the URL.
  596. */
  597. EXTERN_API( Boolean )
  598. NSLGetNextUrl                    (NSLClientAsyncInfoPtr     infoPtr,
  599.                                  char **                urlPtr,
  600.                                  long *                    urlLength);
  601.  
  602. /*
  603.    utility function that returns whether a Neighborhood was found, a pointer to the beginning
  604.    of the Neighborhood, and the length of the Neighborhood.
  605. */
  606. EXTERN_API( Boolean )
  607. NSLGetNextNeighborhood            (NSLClientAsyncInfoPtr     infoPtr,
  608.                                  NSLNeighborhood *        neighborhood,
  609.                                  long *                    neighborhoodLength);
  610.  
  611.  
  612. /*
  613.    NSLErrorToString:    convert a numeric error code to its string equivalent.  Caller must
  614.                            have allocated sufficient space to store both strings.  (Max 255 chars each)
  615.                                   
  616.                           The errorString parameter will return a textual explanation of what is wrong,
  617.                           while the solutionString returns a possible solution to get around the problem
  618. */
  619.  
  620. EXTERN_API( OSStatus )
  621. NSLErrorToString                (NSLError                 theErr,
  622.                                  char *                    errorString,
  623.                                  char *                    solutionString);
  624.  
  625.  
  626. /*
  627.   -----------------------------------------------------------------------------
  628.       Basic API calls: sufficient to create simple requests, and receive answers
  629.   -----------------------------------------------------------------------------
  630. */
  631.  
  632. EXTERN_API( OSStatus )
  633. NSLOpenNavigationAPI            (NSLClientRef *            newRef);
  634.  
  635. EXTERN_API( void )
  636. NSLCloseNavigationAPI            (NSLClientRef             theClient);
  637.  
  638. /*
  639.       NSLPrepareRequest:    creates an NSLRequestRef, sets up some internal data
  640.       notifier is an NSLClientNotifyUPP that will be called when data is available, when the lookup has
  641.     completed, or if an error occurs.  When the notifier is called, the cookie will be the NSLRequestRef.
  642.     If notifier is NULL, then the NSLManager will assume that the request is made synchronously.  This
  643.     should only be used while in a separate thread, so that the client app can still process events, etc.
  644.       
  645.       contextPtr is a void* which is passed as the contextPtr argument when the notifier is called.  
  646.       
  647.       upon exit:
  648.       1) ref will contain a pointer to a NSLRequestRef which must be passed to all other functions
  649.       which require a NSLRequestRef.
  650.       2) infoPtr will point to a newly created ClientAsycnInfoPtr which will be disposed by the manager when the search is completed
  651.       NOTE: Only one search can be running at a time per clientRef.
  652. */
  653.  
  654. EXTERN_API( NSLError )
  655. NSLPrepareRequest                (NSLClientNotifyUPP     notifier,
  656.                                  void *                    contextPtr,
  657.                                  NSLClientRef             theClient,
  658.                                  NSLRequestRef *        ref,
  659.                                  char *                    bufPtr,
  660.                                  unsigned long             bufLen,
  661.                                  NSLClientAsyncInfoPtr * infoPtr);
  662.  
  663.  
  664. /*
  665.    NSLStartNeighborhoodLookup: looking for neighborhoods associated with or neighboring a particular neighborhood
  666.       Passing in NULL for neighborhood will generate a list of a default neighborhood(s)
  667.    
  668. */
  669.  
  670. EXTERN_API( NSLError )
  671. NSLStartNeighborhoodLookup        (NSLRequestRef             ref,
  672.                                  NSLNeighborhood         neighborhood,
  673.                                  NSLClientAsyncInfo *    asyncInfo);
  674.  
  675. /*
  676.    NSLStartServicesLookup: starts looking for entities if the specified type in the specified neighborhood
  677.    
  678. */
  679.  
  680. EXTERN_API( NSLError )
  681. NSLStartServicesLookup            (NSLRequestRef             ref,
  682.                                  NSLNeighborhood         neighborhood,
  683.                                  NSLTypedDataPtr         requestData,
  684.                                  NSLClientAsyncInfo *    asyncInfo);
  685.  
  686.  
  687. /* NSLContinueLookup:  continues a paused/outstanding lookup*/
  688.  
  689. EXTERN_API( NSLError )
  690. NSLContinueLookup                (NSLClientAsyncInfo *    asyncInfo);
  691.  
  692.  
  693. /* NSLCancelRequest: cancels an ongoing search*/
  694.  
  695. EXTERN_API( NSLError )
  696. NSLCancelRequest                (NSLRequestRef             ref);
  697.  
  698. /*
  699.    NSLDeleteRequest: deletes info associated with this ref.  The ClientAsyncInfoPtr will no longer be valid
  700.       This must be called when the client is no longer using this requestRef.
  701. */
  702.  
  703. EXTERN_API( NSLError )
  704. NSLDeleteRequest                (NSLRequestRef             ref);
  705.  
  706.  
  707. /*
  708.   -----------------------------------------------------------------------------
  709.    Utility API calls: use these accessors to manipulate NSL's typed data
  710.   -----------------------------------------------------------------------------
  711. */
  712.  
  713. /* NSLParseServicesRequestPB provides the inverse of NSLMakeRequestPB, filling out the offsets found within newDataPtr*/
  714. /* <--- returns an OSStatus if any errors occur parsing the data */
  715. /* <--- newDataPtr is the construct passed to the plugin */
  716. /* --->    serviceListPtr is the address of a pointer which will be set to point at the portion of the newDataPtr that holds the serviceList to be searched */
  717. /* ---> serviceListLen is the length of the serviceListPtr data pointed to by serviceListPtr */
  718. EXTERN_API( OSStatus )
  719. NSLParseServicesRequestPB        (NSLTypedDataPtr         newDataPtr,
  720.                                  char **                serviceListPtr,
  721.                                  UInt16 *                serviceListLen);
  722.  
  723.  
  724. /* NSLParseServiceRegistrationPB provides for breaking apart a registration request from a client to a plugin*/
  725. /* <--- returns an OSStatus if any errors occur parsing the data */
  726. /* <--- newDataPtr is the construct passed to the plugin */
  727. /* ---> neighborhoodPtr gets set to point at the portion of the newDataPtr that contains the neighborhood */
  728. /* ---> neighborhoodLen is the length of the neighborhood pointed to by neighborhoodPtr */
  729. /* --->    urlPtr is the address of a pointer which will be set to point at the portion of the newDataPtr that holds the url to be registered */
  730. /* ---> urlLen is the length of the url data pointed to by urlPtr */
  731. EXTERN_API( OSStatus )
  732. NSLParseServiceRegistrationPB    (NSLTypedDataPtr         newDataPtr,
  733.                                  NSLNeighborhood *        neighborhoodPtr,
  734.                                  UInt16 *                neighborhoodLen,
  735.                                  char **                urlPtr,
  736.                                  UInt16 *                urlLen);
  737.  
  738. /*
  739.       NSLGetErrorStringsFromResource makes a basic assumption!
  740.       errorString and solutionString both point to valid memory of at least 256 bytes!
  741. */
  742. /* <--- returns an OSStatus if any errors occur */
  743. /* ---> theErr is an OSStatus to be matched against a resource list of errors */
  744. /* ---> fileSpecPtr is a FSSpecPtr to the resource containing the list of errors */
  745. /* ---> errorResID is the resourceID of the NSLI resource of the list of errors */
  746. /* <--> errorString is a pointer to valid memory of at least 256 bytes which will be filled out by the error portion of the error string */
  747. /* <--> solutionString is a pointer to valid memory of at least 256 bytes which will be filled out by the solution portion of the error string */
  748. EXTERN_API( OSStatus )
  749. NSLGetErrorStringsFromResource    (OSStatus                 theErr,
  750.                                  const FSSpec *            fileSpecPtr,
  751.                                  SInt16                 errorResID,
  752.                                  char *                    errorString,
  753.                                  char *                    solutionString);
  754.  
  755. /* <---    Returns true if given service is in the given service list */
  756. /* ---> serviceList is a valid NSLServicesList containing information about services to be searched */
  757. /* ---> svcToFind is an NSLServiceType of a particular service to check if it is in the serviceList */
  758. EXTERN_API( Boolean )
  759. NSLServiceIsInServiceList        (NSLServicesList         serviceList,
  760.                                  NSLServiceType         svcToFind);
  761.  
  762. /* <--- returns an OSStatus if any errors occur parsing the data */
  763. /* --->    svcString is the address of a pointer which will be set to point at the portion of theURL that holds the serviceType of theURL */
  764. /* ---> svcLen is the length of the serviceType pointed to by svcString */
  765. EXTERN_API( OSStatus )
  766. NSLGetServiceFromURL            (char *                    theURL,
  767.                                  char **                svcString,
  768.                                  UInt16 *                svcLen);
  769.  
  770. /* <--- returns the length of a Neighborhood data structure */
  771. /* ---> neighborhood is a valid NSLNeighborhood */
  772. EXTERN_API( long )
  773. NSLGetNeighborhoodLength        (NSLNeighborhood         neighborhood);
  774.  
  775. /*
  776.   -------------------------------------------------------------------------------------
  777.    Utility API calls: use these routines to separate plugin threads from client threads
  778.   -------------------------------------------------------------------------------------
  779. */
  780.  
  781. /* this routine works the same as the Thread manager's routine NewThread, except */
  782. /* that the thread is added to the NSL manager's thread list. */
  783. EXTERN_API( OSErr )
  784. NSLNewThread                    (ThreadStyle             threadStyle,
  785.                                  ThreadEntryProcPtr     threadEntry,
  786.                                  void *                    threadParam,
  787.                                  Size                     stackSize,
  788.                                  ThreadOptions             options,
  789.                                  void **                threadResult,
  790.                                  ThreadID *                threadMade);
  791.  
  792. /* this routine works the same as the Thread manager's routine DisposeThread, except */
  793. /* that the thread is removed from the NSL manager's thread list. */
  794. EXTERN_API( OSErr )
  795. NSLDisposeThread                (ThreadID                 threadToDump,
  796.                                  void *                    threadResult,
  797.                                  Boolean                 recycleThread);
  798.  
  799. #if OLDROUTINENAMES
  800.  
  801. typedef NSLClientAsyncInfo                 ClientAsyncInfo;
  802. typedef NSLPluginAsyncInfo                 PluginAsyncInfo;
  803. typedef NSLTypedData                     TypedData;
  804. typedef NSLPluginData                     PluginData;
  805. typedef NSLClientAsyncInfoPtr             ClientAsyncInfoPtr;
  806. typedef NSLPluginAsyncInfoPtr             PluginAsyncInfoPtr;
  807. typedef NSLTypedDataPtr                 TypedDataPtr;
  808. typedef NSLPluginDataPtr                 PluginDataPtr;
  809.  
  810. #endif  /* OLDROUTINENAMES */
  811.  
  812. #pragma export off
  813.  
  814. #if PRAGMA_STRUCT_ALIGN
  815.     #pragma options align=reset
  816. #elif PRAGMA_STRUCT_PACKPUSH
  817.     #pragma pack(pop)
  818. #elif PRAGMA_STRUCT_PACK
  819.     #pragma pack()
  820. #endif
  821.  
  822. #ifdef PRAGMA_IMPORT_OFF
  823. #pragma import off
  824. #elif PRAGMA_IMPORT
  825. #pragma import reset
  826. #endif
  827.  
  828. #ifdef __cplusplus
  829. }
  830. #endif
  831.  
  832. #endif /* __NSL__ */
  833.  
  834.